<?php

namespace JLPay\Models\Trans\Common;

use JLPay\Models\BaseResponse;

/**
 * 预授权查询响应模型
 */
class PreAuthQueryResponse extends BaseResponse
{
    /**
     * @var string|null 状态 2：成功 3：失败
     */
    protected ?string $status = null;

    /**
     * @var string|null 商户号
     */
    protected ?string $mchId = null;

    /**
     * @var string|null 平台订单号
     */
    protected ?string $transactionId = null;

    /**
     * @var string|null 外部订单号
     */
    protected ?string $outTradeNo = null;

    /**
     * @var string|null 订单时间
     */
    protected ?string $orderTime = null;

    /**
     * @var string|null 交易类型
     */
    protected ?string $payType = null;

    /**
     * @var string|null 交易金额
     */
    protected ?string $totalFee = null;

    /**
     * @var string|null 交易时间
     */
    protected ?string $transTime = null;

    /**
     * @var string|null 预授权状态
     */
    protected ?string $preAuthStatus = null;

    /**
     * @var string|null 预授权金额
     */
    protected ?string $preAuthAmount = null;

    /**
     * @var string|null 预授权时间
     */
    protected ?string $preAuthTime = null;

    /**
     * @var string|null 预授权有效期
     */
    protected ?string $preAuthExpiry = null;

    /**
     * @var string|null 预授权描述
     */
    protected ?string $preAuthDesc = null;

    /**
     * 构造函数
     *
     * @param array|null $responseArray 响应数组
     */
    public function __construct(?array $responseArray = null)
    {
        parent::__construct($responseArray);

        if ($responseArray) {
            $this->status = $responseArray['status'] ?? null;
            $this->mchId = $responseArray['mch_id'] ?? null;
            $this->transactionId = $responseArray['transaction_id'] ?? null;
            $this->outTradeNo = $responseArray['out_trade_no'] ?? null;
            $this->orderTime = $responseArray['order_time'] ?? null;
            $this->payType = $responseArray['pay_type'] ?? null;
            $this->totalFee = $responseArray['total_fee'] ?? null;
            $this->transTime = $responseArray['trans_time'] ?? null;
            $this->preAuthStatus = $responseArray['pre_auth_status'] ?? null;
            $this->preAuthAmount = $responseArray['pre_auth_amount'] ?? null;
            $this->preAuthTime = $responseArray['pre_auth_time'] ?? null;
            $this->preAuthExpiry = $responseArray['pre_auth_expiry'] ?? null;
            $this->preAuthDesc = $responseArray['pre_auth_desc'] ?? null;
        }
    }

    /**
     * 设置状态
     *
     * @param string $status 状态
     * @return $this
     */
    public function setStatus(string $status): self
    {
        $this->status = $status;
        return $this;
    }

    /**
     * 获取状态
     *
     * @return string|null 状态
     */
    public function getStatus(): ?string
    {
        return $this->status;
    }

    /**
     * 设置商户号
     *
     * @param string $mchId 商户号
     * @return $this
     */
    public function setMchId(string $mchId): self
    {
        $this->mchId = $mchId;
        return $this;
    }

    /**
     * 获取商户号
     *
     * @return string|null 商户号
     */
    public function getMchId(): ?string
    {
        return $this->mchId;
    }

    /**
     * 设置平台订单号
     *
     * @param string $transactionId 平台订单号
     * @return $this
     */
    public function setTransactionId(string $transactionId): self
    {
        $this->transactionId = $transactionId;
        return $this;
    }

    /**
     * 获取平台订单号
     *
     * @return string|null 平台订单号
     */
    public function getTransactionId(): ?string
    {
        return $this->transactionId;
    }

    /**
     * 设置外部订单号
     *
     * @param string $outTradeNo 外部订单号
     * @return $this
     */
    public function setOutTradeNo(string $outTradeNo): self
    {
        $this->outTradeNo = $outTradeNo;
        return $this;
    }

    /**
     * 获取外部订单号
     *
     * @return string|null 外部订单号
     */
    public function getOutTradeNo(): ?string
    {
        return $this->outTradeNo;
    }

    /**
     * 设置订单时间
     *
     * @param string $orderTime 订单时间
     * @return $this
     */
    public function setOrderTime(string $orderTime): self
    {
        $this->orderTime = $orderTime;
        return $this;
    }

    /**
     * 获取订单时间
     *
     * @return string|null 订单时间
     */
    public function getOrderTime(): ?string
    {
        return $this->orderTime;
    }

    /**
     * 设置交易类型
     *
     * @param string $payType 交易类型
     * @return $this
     */
    public function setPayType(string $payType): self
    {
        $this->payType = $payType;
        return $this;
    }

    /**
     * 获取交易类型
     *
     * @return string|null 交易类型
     */
    public function getPayType(): ?string
    {
        return $this->payType;
    }

    /**
     * 设置交易金额
     *
     * @param string $totalFee 交易金额
     * @return $this
     */
    public function setTotalFee(string $totalFee): self
    {
        $this->totalFee = $totalFee;
        return $this;
    }

    /**
     * 获取交易金额
     *
     * @return string|null 交易金额
     */
    public function getTotalFee(): ?string
    {
        return $this->totalFee;
    }

    /**
     * 设置交易时间
     *
     * @param string $transTime 交易时间
     * @return $this
     */
    public function setTransTime(string $transTime): self
    {
        $this->transTime = $transTime;
        return $this;
    }

    /**
     * 获取交易时间
     *
     * @return string|null 交易时间
     */
    public function getTransTime(): ?string
    {
        return $this->transTime;
    }

    /**
     * 设置预授权状态
     *
     * @param string $preAuthStatus 预授权状态
     * @return $this
     */
    public function setPreAuthStatus(string $preAuthStatus): self
    {
        $this->preAuthStatus = $preAuthStatus;
        return $this;
    }

    /**
     * 获取预授权状态
     *
     * @return string|null 预授权状态
     */
    public function getPreAuthStatus(): ?string
    {
        return $this->preAuthStatus;
    }

    /**
     * 设置预授权金额
     *
     * @param string $preAuthAmount 预授权金额
     * @return $this
     */
    public function setPreAuthAmount(string $preAuthAmount): self
    {
        $this->preAuthAmount = $preAuthAmount;
        return $this;
    }

    /**
     * 获取预授权金额
     *
     * @return string|null 预授权金额
     */
    public function getPreAuthAmount(): ?string
    {
        return $this->preAuthAmount;
    }

    /**
     * 设置预授权时间
     *
     * @param string $preAuthTime 预授权时间
     * @return $this
     */
    public function setPreAuthTime(string $preAuthTime): self
    {
        $this->preAuthTime = $preAuthTime;
        return $this;
    }

    /**
     * 获取预授权时间
     *
     * @return string|null 预授权时间
     */
    public function getPreAuthTime(): ?string
    {
        return $this->preAuthTime;
    }

    /**
     * 设置预授权有效期
     *
     * @param string $preAuthExpiry 预授权有效期
     * @return $this
     */
    public function setPreAuthExpiry(string $preAuthExpiry): self
    {
        $this->preAuthExpiry = $preAuthExpiry;
        return $this;
    }

    /**
     * 获取预授权有效期
     *
     * @return string|null 预授权有效期
     */
    public function getPreAuthExpiry(): ?string
    {
        return $this->preAuthExpiry;
    }

    /**
     * 设置预授权描述
     *
     * @param string $preAuthDesc 预授权描述
     * @return $this
     */
    public function setPreAuthDesc(string $preAuthDesc): self
    {
        $this->preAuthDesc = $preAuthDesc;
        return $this;
    }

    /**
     * 获取预授权描述
     *
     * @return string|null 预授权描述
     */
    public function getPreAuthDesc(): ?string
    {
        return $this->preAuthDesc;
    }

    /**
     * 转换为数组格式
     *
     * @return array 数组格式的数据
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        $data = array_merge($data, [
            'status' => $this->status,
            'mch_id' => $this->mchId,
            'transaction_id' => $this->transactionId,
            'out_trade_no' => $this->outTradeNo,
            'order_time' => $this->orderTime,
            'pay_type' => $this->payType,
            'total_fee' => $this->totalFee,
            'trans_time' => $this->transTime,
            'pre_auth_status' => $this->preAuthStatus,
            'pre_auth_amount' => $this->preAuthAmount,
            'pre_auth_time' => $this->preAuthTime,
            'pre_auth_expiry' => $this->preAuthExpiry,
            'pre_auth_desc' => $this->preAuthDesc
        ]);

        return $data;
    }
} 